home *** CD-ROM | disk | FTP | other *** search
/ develop, the CD; issue 1 / Apple_Develop_1989.bin / the Palette Manager / Palette.p < prev    next >
Text File  |  1989-09-20  |  1KB  |  71 lines

  1.  
  2. PROGRAM palette
  3.  
  4.  
  5. USES
  6.     MemTypes, QuickDraw, OSIntf, ToolIntf, PackIntf, Traps;
  7.  
  8.  
  9.  
  10.  
  11.  
  12. FUNCTION MakeRedPalette: PaletteHandle;
  13.     VAR
  14.         i:    LONGINT;
  15.         ph:    PaletteHandle;
  16.         c:    RGBColor;
  17.                 
  18.     BEGIN
  19.         ph := NewPalette(254+14,NIL,0,0);
  20.         (* should check for NIL result *)
  21.  
  22.         c.green := 0;
  23.         c.blue := 0;
  24.  
  25.         (*    Make fourteen reds that are inhibited on all *)
  26.         (*    screens except four-bit color *)
  27.         FOR i:=0 TO 13
  28.         DO
  29.         BEGIN
  30.             (* range red component from 1/14 to 14/14 *)
  31.             (* i is a longint, and so can safely be multiplied by 65535 *)
  32.             c.red := (i+1)*65535 DIV 14;
  33.             SetEntryColor(ph,i,c);
  34.             SetEntryUsage(ph,i,pmTolerant+pmInhibitC2+
  35.                     pmInhibitG2+pmInhibitG4+
  36.                     pmInhibitC8+pmInhibitG8,4000);
  37.         END;
  38.  
  39.         (*    Make 254 reds that are inhibited on all *)
  40.         (*    screens except eight-bit color *)
  41.         FOR i:=0 TO 254
  42.         DO
  43.         BEGIN
  44.             (* range red component from 1/14 to 14/14 *)
  45.             (* i is a longint, and so can safely be multiplied by 65535 *)
  46.             c.red := (i+1)*65535 DIV 254;
  47.             SetEntryColor(ph,14+i,c);
  48.             SetEntryUsage(ph,14+i,pmTolerant+pmInhibitC2+
  49.                     pmInhibitG2+pmInhibitG4+
  50.                     pmInhibitC4+pmInhibitG8,0);
  51.         END;
  52.  
  53.         MakeRedPalette := ph;
  54.     END;
  55.  
  56.  
  57.  
  58.  
  59.  
  60. myPP:    PixPatHandle;
  61. myCT:    CTabHandle;
  62.  
  63. myPP := GetPixPat(16);    (* Gets the system color desktop pattern    *)
  64. myCT := myPP^^.patMap^^.pmTable
  65.     FOR j := 0 TO myCT^^.ctSize
  66.     DO
  67.         myCT^^.ctTable[j].value := j;
  68.  
  69.     myCT^^.ctFlags := myCT^^.ctFlags+$4000;    (* .ctFlags aka .transinde *)
  70.                     (* would be bad if bit 14 were already set   *)
  71.